//最⻓回⽂串（easy）:https://leetcode.cn/problems/longest-palindrome/
class Solution
{
public:
	int longestPalindrome(string s)
	{
		// 1. 计数 - ⽤数组模拟哈希表
		int hash[127] = { 0 };
		for (char ch : s)
		{
			hash[ch]++;
		}
		// 2. 统计结果
		int ret = 0;
		for (int x : hash)
		{
			ret += x / 2 * 2;
		}
		return ret < s.size() ? ret + 1 : ret;
	}
};

//增减字符串匹配（easy）: https://leetcode.cn/problems/di-string-match/
class Solution
{
public:
	vector<int> diStringMatch(string s)
	{
		int left = 0, right = s.size(); // ⽤ left，right 标记最⼩值和最⼤值
		vector<int> ret;
		for (auto ch : s)
		{
			if (ch == 'I')
			{
				ret.push_back(left++);
			}
			else
			{
				ret.push_back(right--);
			}
		}
		ret.push_back(left); // 把最后⼀个数放进去
		return ret;
	}
};